package com.fqgj.sentry.common.exception.enums;

import com.fqgj.common.api.enums.ErrorCodeEnum;
import org.springframework.http.HttpStatus;

/**
 * https://github.com/bolasblack/http-api-guide
 * <p>
 * Error Description(Chinese)	Error Description(English)
 * 0	成功	Success
 * 1	未知错误	Unknown error
 * 2	服务暂不可用	Service temporarily unavailable
 * 3	未知的方法	Unsupported openapi method
 * 4	接口调用次数已达到设定的上限	Open api request limit reached
 * 5	请求来自未经授权的IP地址	Unauthorized client IP address:%s
 * 6	无权限访问该用户数据	No permission to access data
 * 7	来自该refer的请求无访问权限	No permission to access data for this referer
 * 100	请求参数无效	Invalid parameter
 * 101	api key无效	Invalid API key
 * 102	session key无效	Session key invalid or no longer valid
 * 103	call_id参数无效	Invalid/Used call_id parameter
 * 104	无效签名	Incorrect signature
 * 105	请求参数过多	Too many parameters
 * 106	未知的签名方法	Unsupported signature method
 * 107	timestamp参数无效	Invalid/Used timestamp parameter
 * 108	无效的user id	Invalid user id
 * 109	无效的用户资料字段名	Invalid user info field
 * 110	无效的access token	Access token invalid or no longer valid
 * 111	access token过期	Access token expired
 * 112	session key过期	Session key expired
 * 114   无效的ip参数 Invalid Ip
 * 210	用户不可见	User not visible
 * 211	获取未授权的字段	Unsupported permission
 * 212	没有权限获取用户的email	No permission to access user email
 * 800	未知的存储操作错误	Unknown data store API error
 * 801	无效的操作方法	Invalid operation
 * 802	数据存储空间已超过设定的上限	Data store allowable quota was exceeded
 * 803	指定的对象不存在	Specified object cannot be found
 * 804	指定的对象已存在	Specified object already exists
 * 805	数据库操作出错，请重试	A database error occurred. Please try again
 * 900	访问的应用不存在	No such biz exists
 * 950	批量操作已开始，请先调用end_batch接口结束前一个批量操作	begin_batch already called, please make sure to call end_batch first
 * 951	结束批量操作的接口调用不应该在start_batch接口之前被调用	end_batch called before start_batch
 * 952	每个批量调用不能包含多于20个接口调用	Each batch API can not contain more than 20 items
 * 953	该接口不适合在批量调用操作中被使用	Method is not allowed in batch mode
 */

/**
 * HTTP状态码	Error_code	Error_msg	备注
 * 500	30600	Internal Server Error	服务器内部错误。
 * 405	30601	Method Not Allowed	不允许的操作（指定了错误的HTTP方法或API）。
 * 400	30602	Request Params Not Valid	请求参数非法。
 * 403	30603	Authentication Failed	权限校验错误 。
 * 402	30604	Quota Use Up Payment Required	无quota。
 * 404	30605	Data Required Not Found	请求数据不存在。
 * 408	30606	Request Time Expires Timeout	请求已超时。
 * 408	30607	Channel Token Timeout	channel_token已经过期。
 * 404	30608	Bind Relation Not Found	绑定关系不存在。
 * 404	30609	Bind Number Too Many	绑定数过多。
 * 409	30610	Duplicate Operation	重复操作。
 * 404	30611	Group Not Found	组不存在。
 */
public enum ErrorCodeEnums implements ErrorCodeEnum {
    //===============sign  权限====================
    sign_error(90000, "sign校验异常", HttpStatus.INTERNAL_SERVER_ERROR),
    permission_error(90000, "没有访问权限", HttpStatus.INTERNAL_SERVER_ERROR),

    //=======================系统错误===================
    internal_server_error(90000, "服务器内部错误", HttpStatus.INTERNAL_SERVER_ERROR),
    param_valid_error(90001, "参数验证失败", HttpStatus.INTERNAL_SERVER_ERROR),
    unknow_error(90002, "未知错误", HttpStatus.INTERNAL_SERVER_ERROR),
    motan_service_error(90003, "motan服务异常", HttpStatus.INTERNAL_SERVER_ERROR),
    request_service_error(90004, "暂不支持的请求格式", HttpStatus.INTERNAL_SERVER_ERROR),
    json_transform_error(90005, "json转换异常", HttpStatus.INTERNAL_SERVER_ERROR),
    email_send_error(90005, "邮件发送异常", HttpStatus.INTERNAL_SERVER_ERROR),


    //===========================管理中心============================
    no_access_right(10000, "没有访问权限", HttpStatus.FORBIDDEN),
    access_expire(10001, "鉴权过期,请重新登录", HttpStatus.FORBIDDEN),
    user_not_exist_error(10002, "用户不存在", HttpStatus.NOT_FOUND),
    password_error(10003, "密码有误", HttpStatus.NOT_FOUND),
    user_is_exist_error(1004, "用户已存在", HttpStatus.OK),

    //应用
    app_not_choose_error(1005, "请先选择应用", HttpStatus.NOT_FOUND),
    app_not_exist_error(1005, "应用不存在", HttpStatus.NOT_FOUND),
    app_is_exist_error(1006, "应用已经存在", HttpStatus.NOT_FOUND),
    app_merchant_is_exist_error(10012, "商户该应用已经存在", HttpStatus.NOT_FOUND),

    //商户
    merchant_level_error(1007, "商户系统管理员，无法删除", HttpStatus.OK),
    merchant_user_error(1008, "用户不是当前的商户，无法删除", HttpStatus.OK),
    //配置管理
    alarm_man_is_exist_error(1009, "报警人已存在", HttpStatus.OK),
    alarm_man_not_exist_error(1010, "报警人不存在", HttpStatus.NOT_FOUND),
    merchant_alarm_man(1011, "该报警人不属于当前操作商户,无法删除", HttpStatus.OK),
    //角色
    role_is_not_exist_error(1013, "没有该角色", HttpStatus.NOT_FOUND),
    role_have_user_error(1014, "角色下仍有用户，不能删除", HttpStatus.NOT_FOUND),

    //权限组
    app_group_manager_is_exit_error(1015, "该权限组已经存在", HttpStatus.OK),
    app_group_manager_not_exist_error(1016, "没有该权限组", HttpStatus.NOT_FOUND),

    //===========================策略中心===============================
    policy_set_event_is_exit(2001, "策略集对应的事件已经存在", HttpStatus.OK),
    policy_set_is_not_exit(2002, "策略集不存在", HttpStatus.NOT_FOUND),
    policy_set_is_exit(2003, "该应用下还有策略集存在", HttpStatus.OK),

    policy_executor_not_error(2005, "执行者不存在或不是待发布和线上版本", HttpStatus.NOT_FOUND),
    policy_executor_has_policy_error(2006, "当前执行者下还有策略", HttpStatus.OK),
    policy_executor_is_error(2007, "执行者已经存在", HttpStatus.OK),


    policy_execute_result_is_exist_error(2008, "策略执行结果已存在", HttpStatus.OK),
    policy_execute_result_not_exist_error(2009, "策略执行结果已存在", HttpStatus.NOT_FOUND),

    policy_set_has_executor(2003, "策略集下面还有执行者", HttpStatus.OK),

    policy_weight_size_error(2003, "策略权重入参有误", HttpStatus.OK),

    rule_object_error(2003, "规则配置有误，请进行检查或联系管理员！", HttpStatus.OK),

    sort_error(2004, "排序异常", HttpStatus.OK),

    //事件
    event_code_is_exist_error(2021, "事件编码已存在", HttpStatus.OK),
    event_code_is_not_error(2022, "事件编码为空", HttpStatus.OK),
    event_is_not_exist_error(2004, "事件不存在", HttpStatus.NOT_FOUND),

    //字段
    column_has_event(2024, "字段使用此事件", HttpStatus.NOT_FOUND),
    column_is_not_exist_error(2025, "字段不存在", HttpStatus.NOT_FOUND),
    column_code_is_not_exist_error(2026, "字段名不存在", HttpStatus.NOT_FOUND),
    column_code_is_exist_error(2027, "字段名已存在", HttpStatus.OK),
    column_is_temporary_error(2028, "临时字段", HttpStatus.OK),

    //规则字段关联
    rule_column_has_column(2029, "该字段已被规则使用，暂时无法删除", HttpStatus.OK),

    anti_query_no_params_error(2029, "请输入查询值", HttpStatus.OK),
    anti_query_error(2029, "暂不支持该功能查询", HttpStatus.OK),
    anti_query_not_exist_order_error(2029, "该订单号暂无记录", HttpStatus.OK);


    private Integer code;
    private String msg;
    private HttpStatus httpStatus;


    ErrorCodeEnums(Integer code, String msg, HttpStatus httpStatus) {
        this.code = code;
        this.msg = msg;
        this.httpStatus = httpStatus;
    }

    public ErrorCodeEnums setCode(Integer code) {
        this.code = code;
        return this;
    }

    public ErrorCodeEnums setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public ErrorCodeEnums setHttpStatus(HttpStatus httpStatus) {
        this.httpStatus = httpStatus;
        return this;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public HttpStatus getHttpStatus() {
        return httpStatus;
    }
}
